#pragma once

#include "glm/glm.hpp"
#include "SceneCamera.h"
#include "ScriptableEntity.h"
#include "Core/Time.h"
#include "glm/gtc/matrix_transform.hpp"
namespace Orange {

	struct TagComponent {
		std::string tag = "";

		TagComponent() = default;
		TagComponent(const TagComponent&) = default;
		TagComponent(const std::string& name) :tag(name) {

		};


	};
	struct TransformComponent {
		glm::vec3 Transtion = glm::vec3(0.0f , 0.0f , 0.0f);
		glm::vec3 Rotation = glm::vec3(0.0f , 0.0f , 0.0f);
		glm::vec3 Scale = glm::vec3(1.0f , 1.0f , 1.0f);

		TransformComponent() = default;
		TransformComponent(const TransformComponent&) = default;
		TransformComponent(const glm::vec3& transtion):Transtion(transtion) {
		
		};

		glm::mat4 GetTransform() {
			glm::mat4 rotation = glm::rotate(glm::mat4(1.0f), Rotation.x, { 1,0,0 })
				* glm::rotate(glm::mat4(1.0f), Rotation.y, { 0,1,0 })
				* glm::rotate(glm::mat4(1.0f), Rotation.z, { 0,0,1 });
			return glm::translate(glm::mat4(1.0f), Transtion)
				* rotation
				* glm::scale(glm::mat4(1.0f), Scale);
		}

	};

	struct SpriteRendererComponent {
		glm::vec4 Color = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f);

		SpriteRendererComponent() = default;
		SpriteRendererComponent(const SpriteRendererComponent&) = default;
		SpriteRendererComponent(const glm::vec4& color) :Color(color) {};

	};

	struct CameraComponent {
		SceneCamera camera;
		bool Primary = false;
		bool FixAspecRadius = false;
		CameraComponent() = default;
		CameraComponent(const CameraComponent&) = default;
	};

	struct NativeScriptComponent {
		ScriptableEntity* Instance = nullptr;
		
		ScriptableEntity*(*OnCreateEntity)();
		void (*OnDestoryEntity)(NativeScriptComponent*);

		template <typename T>
		void Bind() {
			OnCreateEntity = []() { return static_cast<ScriptableEntity*>(new T()); };
			OnDestoryEntity = [](NativeScriptComponent* nsc) {
				delete nsc->Instance; 
				nsc->Instance = nullptr; };
	
		}
	};
}